<template>
	<view class="user clearfix  hv100 ">
		<cu-custom bgColor="bg-white" isBack>
			<block slot="content">余额支付</block>
			<block slot="right"><text class="mr15" @click="pushPage('/pages/usertransfer/payhistory')">付款记录</text></block>
		</cu-custom>
		<view class="paylines"></view>
		<view class="flex flex-direction bg-white px15">
			<view class="flex align-center justify-between py15">
				<text>余额</text>
				<text>{{balance}}</text>
			</view>
			<view class="payline"></view>
			<view class="flex align-center justify-between py15">
				<text>支付金额</text>
				<input v-model="money" maxlength="10" class="f14 text-right" type="number" placeholder="请设置支付金额" />
			</view>
			<view class="payline"></view>
			<view class="flex align-center justify-between py15">
				<text>支付密码</text>
				<input maxlength="6" v-model="paypwd" class="f14 text-right" password placeholder="请输入支付密码" />
			</view>
			<view class="payline"></view>
		</view>
		<view class="red-button discenter" @click="qrcodes">生成付款码</view>
	</view>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
	data() {
		return {
			money:'',
			balance:'',
			paypwd:'',
		}
	},
	onLoad() {
		this.getData()
	},
	methods: {
		async getData() {
			let {
				data
			} = await this.$http.post('wallet.paypages', {}, { tipConfig: { storeBlock: true } })
			this.balance=data.num
		},
		async qrcodes() {
			if(this.money==''||this.money==0){
				uni.showToast({
					title:'请设置支付金额',
					icon:"none"
				})
				return false
			}
			if(this.paypwd==''){
				uni.showToast({
					title:'请输入支付密码',
					icon:"none"
				})
				return false
			}
			let params={
				num:this.money,
				payPassword:this.paypwd,
			}
			let {data:{logId,type}} = await this.$http.post('wallet.paypageqrcode', params, { tipConfig: { storeLoading: true, isSuccessTip: true} })
			this.pushPage('/pages/usertransfer/transferqrcode?logId='+logId+'&money='+this.money+'&type='+type)
			
		},
		
	}
}
</script>

<style lang="less">
page{
	background-color: #FFFFFF;
}
.payline{
	width: 100%;
	height: 2rpx;
	background-color: #F2F2F2;
}
.paylines{
	width: 100%;
	height: 10rpx;
	background-color: #F2F2F2;
}
.red-button{
	width: calc(100% - 60rpx);
	margin-left: 30rpx;
	height: 90rpx;
	border-radius: 10rpx;
	background-color: #D73329;
	color: #FFFFFF;
	margin-top:80rpx ;
}
</style>
